package com.fdb.efp.nls.service.impl;

import com.fdb.basic.framework.core.base.FrameworkService;
import com.fdb.basic.framework.core.constant.MonAlrmLvlEnums.MonAlrmLvlEnum;
import com.fdb.basic.framework.core.util.DateTool;
import com.fdb.basic.framework.core.util.FileOperateUtil;
import com.fdb.basic.framework.core.util.SFTPUtil;
import com.fdb.basic.framework.core.util.StringUtil;
import com.fdb.efp.nls.common.constant.HjPrdBizEnums;
import com.fdb.efp.nls.service.facade.AccLedgerBatchService;
import com.fdb.efp.esb.service.bo.req.hj.ReqDownLoadFileBean;
import com.fdb.efp.esb.service.facade.hj.DownLoadFileService;
import com.fdb.efp.nls.service.facade.AccLedgerDownloadFileTempService;
import com.fdb.efp.nls.service.facade.AccLedgerFileTempService;
import com.fdb.efp.nls.service.facade.AccLedgerService;
import com.fdb.efp.nls.service.facade.AccoutErroTempService;
import com.fdb.efp.nls.service.vo.AccLedgerDownloadFileTempVO;
import com.fdb.efp.nls.service.vo.AccLedgerFileTempVO;
import com.fdb.efp.nls.service.vo.AccLedgerVO;
import com.fdb.efp.nls.service.vo.AccoutErroTempVO;
import com.jcraft.jsch.JSchException;
import org.apache.commons.vfs.FileSystemException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStreamWriter;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;

@Service("accLedgerBatchService")
public class AccLedgerBatchServiceImpl implements AccLedgerBatchService, FrameworkService {

	private static Logger logger = LoggerFactory.getLogger(AccLedgerBatchServiceImpl.class);
	private final static String curdate = "cur_date";
	private final static String loanPrincipalShort = "loan_principal_short";
	private final static String loanFlushPrincipalShort = "loan_flush_principal_short";
	private final static String repayNormalPrincipalShort = "repay_normal_principal_short";
	private final static String repayInterest = "repay_interest";
	private final static String provisionInterest = "provision_interest";
	private final static String repayOverduePrincipal = "repay_overdue_principal";
	private final static String intoOverdueRemainPrincipalShort = "into_overdue_remain_principal_short";

	private static String LEDGER_FILE_NAME = "IFP_UL_0101_OCM_PMS001_";

	private static String DATA_SEPARATOR = "|";// 数据分隔符

	private static String TXT_SUFFIX = ".txt";// txt文件后缀
	private static String OK_SUFFIX = ".ok";// ok文件后缀

	@Value("${analysis.accLedgerFilePath}")
	private String accLedgerFilePath;// 生成的并账文件存放路径

	@Value("${analysis.accLedgerFileRemotePath}")
	private String accLedgerFileRemotePath;// 并账文件上传到互金服务器的路径

	/** sftp用户名 */
	@Value("${analysis.hjUserName}")
	private String hjUserName;

	/** sftp密码 */
	@Value("${analysis.hjPassword}")
	private String hjPassword;

	/** sftp主机ip */
	@Value("${analysis.hjFtpHost}")
	private String hjFtpHost;

	/** sftp主机端口 */
	@Value("${analysis.hjFtpPort}")
	private int hjFtpPort;

	@Autowired
	private AccLedgerService accLedgerService;

	@Autowired
	private AccLedgerFileTempService accLedgerFileTempService;

	@Autowired
	private AccoutErroTempService accoutErroTempService;

	@Autowired
	private AccLedgerDownloadFileTempService accLedgerDownloadFileTempService;

	@Autowired
	@Qualifier("downLoadFileService")
	private DownLoadFileService downLoadFileService;// 贷款文件下载通知

	private static final int ACC_LEDGER_NUM = 7;// 马上并账文件标准化信息数量
	
	// 马上并账信息指标、指标名称映射关系
	public static Map<String, String> indexMap = new HashMap<String,String>();
	static {
		indexMap.put("cur_date", "账务日期");
		indexMap.put("loan_principal_short", "短期贷款本金放款金额");
		indexMap.put("loan_flush_principal_short", "短期贷款本金撤销金额");
		indexMap.put("repay_normal_principal_short", "短期正常本金还款");
		indexMap.put("repay_interest", "正常利息归还");
		indexMap.put("provision_interest", "每日计提利息");
		indexMap.put("repay_overdue_principal", "逾期本金还款金额");
		indexMap.put("into_overdue_remain_principal_short", "新增短期贷款的逾期本金");
	}
	
	/**
	 * 同步马上的数据 并账文件
	 * 
	 * @description:TODO
	 * @return
	 * @throws Exception
	 * @date:2019年1月3日 上午11:30:49
	 * @author:cenyj
	 */
	public boolean batchAccLedgerFromMaTxt() throws Exception {

		boolean rs = false;
		try {
			// 1读取同步过来的临时表数据
			logger.info("读取同步过来的临时表数据!");
			// 校验马上提供的并账文件的数量及项目类型的准确性 后的数据
			List<AccLedgerFileTempVO> tempList = accLedgerFileTempService.getAccLedgerFileTempDaoList();
			// 并账信息为空，返回false
			if (Objects.isNull(tempList)) {
				logger.info("日终批量-马上并账信息为空！");
				return rs;
			}

			// 2解析同步过来的临时表数据
			// 3解析出来的数据对应保存到本地表
			AccLedgerVO accLedgerModel = new AccLedgerVO();
			logger.info("读取同步过来的临时表数据条数：" + tempList.size());
			if (tempList != null && tempList.size() > 0) {
				// 先判断同步过来的临时表的数据是否是完全正确的七条数据，如果不是，则记录异常并抛出异常
				if (tempList.size() != 8) {
					// 主要是三种场景
					// 1，条数不对
					// 记录异常 并抛出异常 中断
					String tableName = "AccLedger并账文件表";
					String erroMsg = "同步到本地表过程";
					String tempTotal = "";
					String acountTotal = "";
					String type = "3";
					String updateDelInster = "";
					String no = "";
					String eMsg = "数据条数不对，临时表同步到本地表失败";
					logger.info("数据条数不对，临时表同步到本地表失败");
					accoutErroTempService.accountErroMsg(tableName, erroMsg, tempTotal, acountTotal, type, updateDelInster, no, eMsg);
					rs = false;
					return false;
				}
				// 2，有重复的账务项
				Boolean isRepeat = tempList.stream().collect(Collectors.groupingBy(AccLedgerFileTempVO::getField)).values().stream()
						.map(List::size).anyMatch(size -> size > 1);
				if (isRepeat == true) {
					// 记录异常 并抛出异常 中断
					String tableName = "AccLedger并账文件表";
					String erroMsg = "同步到本地表过程";
					String tempTotal = "";
					String acountTotal = "";
					String type = "3";
					String updateDelInster = "";
					String no = "";
					String eMsg = "数据有重复，临时表同步到本地表失败";
					logger.info("数据有重复，临时表同步到本地表失败");
					accoutErroTempService.accountErroMsg(tableName, erroMsg, tempTotal, acountTotal, type, updateDelInster, no, eMsg);
					rs = false;
					return false;
				}
				for (int i = 0; i < tempList.size(); i++) {
					// 3，有不存在的账务项
					String[] amts = { curdate, loanPrincipalShort, loanFlushPrincipalShort, repayNormalPrincipalShort, repayInterest,
							provisionInterest, repayOverduePrincipal, intoOverdueRemainPrincipalShort };
					String temp = tempList.get(i).getField();

					boolean flag = Arrays.asList(amts).contains(temp);// "﻿cur_date"

					if (flag == false) {
						// 记录异常 并抛出异常 中断

						/**/String tableName = "AccLedger并账文件表";
						String erroMsg = "同步到本地表过程";
						String tempTotal = "";
						String acountTotal = "";
						String type = "3";
						String updateDelInster = "";
						String no = "";
						String eMsg = "数据有误，有不存在的账务项" + tempList.get(i).getField() + ",临时表同步到本地表失败";
						logger.info("数据有误，有不存在的账务项,临时表同步到本地表失败");
						accoutErroTempService.accountErroMsg(tableName, erroMsg, tempTotal, acountTotal, type, updateDelInster, no, eMsg);
						rs = false;
						return false;
					}
					
					//******************************************************************//
					//校验马上并账信息指标和指标名称映射是否正确
					boolean checkFieldNameRes = checkIndexFieldAndIndexFieldName(tempList);
					if (checkFieldNameRes == false) {
						rs = false;
						return rs;
					}
					//******************************************************************//
					
					// fileTemp.getField() 去掉下划线 set﻿curDate
					String[] strArr = tempList.get(i).getField().split("_");
					StringBuffer stringBuffer = new StringBuffer();
					for (String string : strArr) {
						String upperStr = string.substring(0, 1).toUpperCase() + string.substring(1);
						stringBuffer.append(upperStr);
					}
					String retStr = new String(stringBuffer);
					String curdate = "﻿curDate".toUpperCase();
					if (retStr.toUpperCase().equals(curdate) || retStr.toUpperCase().equals("CurDate".toUpperCase())) {// i == 0 ||
						logger.info("临时表第一个行记录日期：" + tempList.get(i).getFieleValues());
						logger.info("临时表第一个行记录日期set+retStr：" + retStr); // setCurDate
						Class<AccLedgerVO> clazz = AccLedgerVO.class;
						java.lang.reflect.Method method = clazz.getMethod("set" + "CurDate", new Class[] { String.class });
						method.invoke(accLedgerModel, tempList.get(i).getFieleValues());

						logger.info("临时表第一个行记录日期method：" + method);
					} else {
						Class<AccLedgerVO> clazz = AccLedgerVO.class;
						java.lang.reflect.Method method = clazz.getMethod("set" + retStr, new Class[] { BigDecimal.class });
						method.invoke(accLedgerModel, new BigDecimal(tempList.get(i).getFieleValues()));
					}

				}
				//******************************************************************//
				int num = 0;
				// 查询马上并账明细信息是否存在，存在则更新，不存在则新增
				AccLedgerVO queryAccLedgerModel = accLedgerService.queryByPk(accLedgerModel);
				if(Objects.nonNull(queryAccLedgerModel)) {
					num = accLedgerService.updateByPk(accLedgerModel);
				} else {
					num = accLedgerService.insert(accLedgerModel);
				}
				//******************************************************************//
				// 把临时表的值读取出来放到
				if (num != 1) {
					logger.info("新增或更新数据发生异常!");
					String tableName = "AccLedger并账文件表";
					String erroMsg = "新增或更新数据发生异常!";
					String tempTotal = "";
					String acountTotal = "";
					String type = "3";
					String updateDelInster = "新增";
					String no = "";
					String eMsg = "新增或更新数据发生异常!";
					accoutErroTempService.accountErroMsg(tableName, erroMsg, tempTotal, acountTotal, type, updateDelInster, no, eMsg);
					rs = false;
					return false;
				} else {
					logger.info("本地表新增或更新数据成功!");
					
					//******************************************************************//
					//设置马上并账信息模板表交易金额、渠道日期为空 
					int udpNullNum = accLedgerDownloadFileTempService.updateAmountAndChannelDate2Null();
					if (udpNullNum != ACC_LEDGER_NUM) {
						String tableName = "AccLedger并账文件表";
						String errorMsg = "更新并账文件标准化信息交易金额、渠道日期为空出错，更新条数为["+udpNullNum+"]，实际需要更新条数["+ACC_LEDGER_NUM+"]";
						addErrorInfo(tableName, MonAlrmLvlEnum.SERIOUS.getEnname(), errorMsg, errorMsg);
						logger.error(errorMsg);
						rs = false;
						return rs;
					}
					// 根据tempList.get(i).getFieldName()和acc_ledger_file_temp的NARRATIVE交易描述对应，修改为对应的交易金额
					//******************************************************************//
					
					String changeDate = tempList.get(0).getFieleValues();
					int rsUpdate = accLedgerDownloadFileTempService.update(changeDate);
					if (rsUpdate != ACC_LEDGER_NUM) {
						logger.info("转换为标准格式时出错!");
						String tableName = "AccLedger并账文件表";
						String erroMsg = "转换为标准格式时出错，更新条数为["+rsUpdate+"]，实际需要更新条数["+ACC_LEDGER_NUM+"]";
						String tempTotal = "";
						String acountTotal = "";
						String type = "3";
						String updateDelInster = "";
						String no = "";
						String eMsg = "转换为标准格式时出错，更新条数为["+rsUpdate+"]，实际需要更新条数["+ACC_LEDGER_NUM+"]";
						accoutErroTempService.accountErroMsg(tableName, erroMsg, tempTotal, acountTotal, type, updateDelInster, no, eMsg);
						rs = false;
						return false;
					} else {
						logger.info("标准化并账文件开始!");
						// 按要求格式生成txt文件
						File file = getCtrLoanContBatchAppFile();
						if (file == null) {
							String tableName = "AccLedger并账文件表";
							String erroMsg = "生成文件出错";
							String tempTotal = "";
							String acountTotal = "";
							String type = "3";
							String updateDelInster = "";
							String no = "";
							String eMsg = "生成文件出错或通知互金失败";
							accoutErroTempService.accountErroMsg(tableName, erroMsg, tempTotal, acountTotal, type, updateDelInster, no,
									eMsg);
							rs = false;
							return false;

						} else {
							logger.info("标准化并账文件成功生成!");
						}
					}
					logger.info("acc_ledger_file_temp的并账数据修改成功!");
				}
			}
			logger.info("并账数据成功!");
			rs = true;

		} catch (Exception e) {
			logger.info("并账数据过程发生异常!", e);
			logger.error("并账数据发生异常!", e);
			e.printStackTrace();
			String tableName = "AccLedger并账文件表";
			String erroMsg = "数据发生异常!";
			String tempTotal = "";
			String acountTotal = "";
			String type = "3";
			String updateDelInster = "";
			String no = "";
			String eMsg = e.getMessage();
			accoutErroTempService.accountErroMsg(tableName, erroMsg, tempTotal, acountTotal, type, updateDelInster, no, eMsg);
			rs = false;
			return false;
		}
		return rs;
	}

	public File getCtrLoanContBatchAppFile() {

		File file = null;
		try {
			logger.info("开始读acc_ledger_file_temp表数据.....");
			String fileName = "";
			// 1读取同步过来的临时表数据
			List<AccLedgerDownloadFileTempVO> tempList = accLedgerDownloadFileTempService.getAccLedgerDownloadFileTempList();
			if (Objects.nonNull(tempList) && tempList.size() > 0) {
				logger.info("查询出[" + tempList.size() + "]条acc_ledger_file_temp表数据");
				// String filePath, List<T> lists, String operation
				String localUploadPath = accLedgerFilePath;
				logger.info("路径accLedgerFilePath：" + accLedgerFilePath);

				SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");// new SimpleDateFormat("yyyyMMddHHmmss");//
				String currDate = sdf.format(new Date());
				String changeDate = tempList.get(0).getChannelDate();
				if (changeDate == null || "".equals(changeDate) || changeDate.length() != 8) {
					String tableName = "AccLedger并账文件表";
					String erroMsg = "账务日期格式不对!";
					String tempTotal = "";
					String acountTotal = "";
					String type = "3";
					String updateDelInster = "";
					String no = "";
					String eMsg = "文件生成失败！";
					accoutErroTempService.accountErroMsg(tableName, erroMsg, tempTotal, acountTotal, type, updateDelInster, no, eMsg);
					return null;
				}
				currDate = changeDate;// sdf.format(changeDate);//这个转换报错
				fileName = LEDGER_FILE_NAME + currDate + TXT_SUFFIX;
				file = FileOperateUtil.writeTxt(localUploadPath + LEDGER_FILE_NAME + currDate + TXT_SUFFIX, tempList, DATA_SEPARATOR);
				if (file != null) {
					// 并账文件生成成功后，生成ok文件
					// List<String> listOK = new ArrayList();
					String ok = "OCM_acc_ledger_download_file_temp=" + tempList.size();
					// listOK.add(ok);
					File fileOk = writeOk(localUploadPath + LEDGER_FILE_NAME + currDate + OK_SUFFIX, ok);
					if (fileOk != null) {
						// 把生成的并账文件放到互金服务器
						logger.info("生成的并账文件放到互金服务器方法开始");
						String fileNameFromPath = localUploadPath + LEDGER_FILE_NAME + currDate + TXT_SUFFIX;// 全路径
						logger.info("上传路径fileNameFromPath:" + fileNameFromPath);
						boolean fileUploadRs = upLoadAccLedgerFileToFtp(fileName, fileNameFromPath);// 此处注释 后续开放//true;
						logger.info("生成的并账文件放到互金服务器方法结果:" + fileUploadRs);
						if (fileUploadRs == true) {
							// 并账文件上传成功后上传ok文件
							String fileNameOk = LEDGER_FILE_NAME + currDate + OK_SUFFIX;
							String fileNameFromPathOk = localUploadPath + LEDGER_FILE_NAME + currDate + OK_SUFFIX;// 全路径
							boolean fileUploadOK = upLoadAccLedgerFileToFtp(fileNameOk, fileNameFromPathOk);
							if (fileUploadOK == true) {
								// 文件生成成功通知互金
								logger.info("调用通知互金接口开始");
								ReqDownLoadFileBean reqDownLoadFileBean = new ReqDownLoadFileBean();
								reqDownLoadFileBean.setFileNm(fileName);// "IFP_UL_0101_OCM_PMS001_20190107.txt"
								reqDownLoadFileBean.setProdType(HjPrdBizEnums.PrdCodeEnum.PRD_CODE_MS.getValue());
								reqDownLoadFileBean.setPrtnrCd("001");// 001-马上贷 002-度小满

								boolean rs = downLoadFileService.DownLoadFileNotice(reqDownLoadFileBean);
								if (rs == false) {
									String tableName = "AccLedger并账文件表";
									String erroMsg = "通知互金失败!";
									String tempTotal = "";
									String acountTotal = "";
									String type = "3";
									String updateDelInster = "";
									String no = "";
									String eMsg = "文件已经上传成功，只是通知互金失败！";
									accoutErroTempService.accountErroMsg(tableName, erroMsg, tempTotal, acountTotal, type, updateDelInster,
											no, eMsg);
									return null;
								}
								logger.info("调用通知互金接口结束");
							}
						}
					}

				}
			} else {
				logger.info("acc_ledger_file_temp表数据为空,开始生成空文件.....");

				String localUploadPath = accLedgerFilePath;
				logger.info("空文件生成路径accLedgerFilePath：" + accLedgerFilePath);
				SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");// new SimpleDateFormat("yyyyMMddHHmmss");//
				String currDate = tempList.get(0).getChannelDate(); // sdf.format(new Date());

				file = new File(localUploadPath + LEDGER_FILE_NAME + currDate + TXT_SUFFIX);
				if (file.exists()) {
					file.delete();
				}
				file.createNewFile();
				return null;
			}
			logger.info("acc_ledger_file_temp表数据文件生成成功：" + file == null ? "文件为空" : file.getPath());
			return file;
		} catch (Exception e) {
			logger.error("acc_ledger_file_temp表数据文件生成失败:", e);
			return null;
		}
	}

	/**
	 * 1、上传并账文件到互金文件服务器<br>
	 * 
	 * @param fileBinStr
	 * @param fileName
	 * @return
	 * @date:2018年12月15日 上午11:02:36
	 * @author:cenyj
	 */
	private boolean upLoadAccLedgerFileToFtp(String fileName, String fileNameFromPath) {
		SFTPUtil sftpUtil = null;
		boolean fileUpFlag = false;
		try {
			// 连接互金文件服务器，上传并账文件到互金文件服务器 "piccs", "piccs123", "10.139.2.48", 22
			String hjFtpUserName = hjUserName;
			String hjFtpUserPwd = hjPassword;
			String hjIp = hjFtpHost;
			int hjPort = hjFtpPort;
			sftpUtil = new SFTPUtil(hjFtpUserName, hjFtpUserPwd, hjIp, hjPort);
			String filePathTo = accLedgerFileRemotePath;
			logger.info("互金文件服务器信息：" + hjFtpUserName + " Pwd  " + hjIp + " " + hjPort);
			logger.info("互金文件服务器的存放文件位置：" + filePathTo);
			// fileUpFlag = sftpUtil.upFile("/home/piccs/opf/",
			// "IFP_UL_0101_OCM_PMS001_20190110.txt",
			// "F:/IFP_UL_0101_OCM_PMS001_20190110.txt", true, false);
			fileUpFlag = sftpUtil.upFile(filePathTo, fileName, fileNameFromPath, true, false);
		} catch (FileSystemException e) {
			logger.error("上传并账文件到互金文件服务器出现异常：" + e.getMessage());
		} catch (JSchException e) {
			logger.error("上传并账文件到互金文件服务器出现异常：" + e.getMessage());
		} catch (Exception e) {
			logger.error("上传并账文件到互金文件服务器出现异常：" + e.getMessage());
		}
		return fileUpFlag;
	}

	/**
	 * 
	 * @Description 将数据写入传入的file中
	 * @param file
	 * @param lists
	 * @return
	 * @throws Exception
	 */
	public static <T> File writeOk(String filePath, String outputStr) throws Exception {
		OutputStreamWriter out = null;
		FileOutputStream fos = null;
		File file = null;
		try {
			file = new File(filePath);
			if (file.exists()) {
				file.delete();
			}
			file.createNewFile();
			fos = new FileOutputStream(file);
			// out = new OutputStreamWriter(fos,"GBK");
			out = new OutputStreamWriter(fos, "UTF-8");
			out.write(outputStr);
			out.write("\r\n");

			logger.info("文件格式" + out.getEncoding());
		} catch (Exception e) {
			logger.error(e.getMessage(), e);
			throw new RuntimeException(e);
		} finally {
			if (out != null) {
				out.flush();
				out.close();
			}
			if (fos != null) {
				fos.flush();
				fos.close();
			}
		}
		return file;
	}
	
	/**
	 * 
	 * 校验马上并账信息指标和指标名称映射是否正确<br>
	 * 0.1:ludayong:2019年7月4日 上午9:31:30:新增<br>
	 * @author ludayong
	 * @since 2019年7月4日 上午9:31:30
	 * @date 2019年7月4日 上午9:31:30
	 * @version 0.1
	 */
	private boolean checkIndexFieldAndIndexFieldName(List<AccLedgerFileTempVO> accLedList) {
		boolean result = true;
		logger.info("并账信息指标和指标名称映射校验开始......");
		// 马上并账信息不为空
		if(Objects.nonNull(accLedList) && !accLedList.isEmpty()) {
			// 马上并账指标名称信息
			for (AccLedgerFileTempVO accLedgerFileTempVO : accLedList) {
				// 指标
				String field = accLedgerFileTempVO.getField();
				// 指标名称
				String fieldName = accLedgerFileTempVO.getFieldName();
				// 比对的指标名称信息
				String cFildName = indexMap.get(field);
				// 比对的指标名称信息不为空
				if(!StringUtil.isNullorBank(cFildName)) {
					//马上并账信息指标和指标名称映射不正确，返回false
					if(!cFildName.equals(fieldName)) {
						String tableName = "AccLedger并账文件表";
						String errorMsg = "并账信息指标和指标名称映射不正确，指标["+field+"]，指标名称["+fieldName+"]，请检查！";
						addErrorInfo(tableName, MonAlrmLvlEnum.SERIOUS.getEnname(), errorMsg, errorMsg);
						logger.error(errorMsg);
						result = false;
						return result;
					}
				}else {
					String tableName = "AccLedger并账文件表";
					String errorMsg = "并账信息指标和指标名称映射不存在，指标["+field+"]，指标名称["+fieldName+"]，请检查！";
					addErrorInfo(tableName, MonAlrmLvlEnum.SERIOUS.getEnname(), errorMsg, errorMsg);
					logger.error(errorMsg);
					result = false;
					return result;
				}
			}
		}
		logger.info("并账信息指标和指标名称映射校验结束......校验结果["+result+"]");
		return result;
	}
	
	/**
	 * 
	 * 记录异常信息 <br>
	 * 0.1:ludayong:2019年7月4日 下午4:29:39:新增 <br>
	 * @author ludayong
	 * @since 2019年7月4日 下午4:29:39
	 * @date 2019年7月4日 下午4:29:39
	 * @version 0.1
	 */
	private void addErrorInfo(String tableName, String errorType, String errorMsg, String remark) {
		AccoutErroTempVO accoutErroTempVO = new AccoutErroTempVO();
		// 表名
		accoutErroTempVO.setTableName(tableName);
		// 错误级别
		accoutErroTempVO.setErroType(errorType);
		// 错误信息
		accoutErroTempVO.setErroMsg(errorMsg);
		// 备注
		accoutErroTempVO.setRemark(remark);
		// 创建时间
		accoutErroTempVO.setCreateData(DateTool.getCurrentDateTime());
		// 修改时间
		accoutErroTempVO.setLastModifyTime(DateTool.getCurrentDateTime());
		// 记录异常信息
		accoutErroTempService.insert(accoutErroTempVO);
	}
}
